package com.example.basicknowledge.进度条;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.DragEvent;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.example.basicknowledge.R;

import org.w3c.dom.Text;

public class ProgressActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener, RatingBar
        .OnRatingBarChangeListener {

    ProgressBar progressBar;
    ProgressBar progressBarHorizontal;
    SeekBar seekBar;
    SeekBar seekBarDiscrete;
    RatingBar ratingBar;
    TextView textView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.progress_activity);

        progressBar = (ProgressBar)findViewById(R.id.progressBar);
        progressBar.setProgress(10);

        progressBarHorizontal = (ProgressBar)findViewById(R.id.progressBar2);
        progressBarHorizontal.setProgress(10);
        progressBarHorizontal.setSecondaryProgress(50);

        seekBar = (SeekBar)findViewById(R.id.seekBar);
        seekBar.setOnSeekBarChangeListener(this);

        seekBarDiscrete = (SeekBar)findViewById(R.id.seekBar2);
        seekBarDiscrete.setOnSeekBarChangeListener(this);

        ratingBar = (RatingBar)findViewById(R.id.ratingBar);
        ratingBar.setOnRatingBarChangeListener(this);

        textView = (TextView)findViewById(R.id.status_textView);
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
        System.out.println("i = " + i + "  b = " + b);
        textView.setText("i = " + i + "  b = " + b);
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        System.out.println(seekBar.getProgress());
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        System.out.println(seekBar.getProgress());
    }

    @Override
    public void onRatingChanged(RatingBar ratingBar, float v, boolean b) {
        System.out.println("v = " + v + "  b = " + b);
        textView.setText("v = " + v + "  b = " + b);
    }
}
